/*
 * voice_server.h
 *
 * Created on: Feb 2017
 * 		Author : macro gu
 *
 *
 */

#pragma once

#include <thread>
#include <sstream>
#include <map>
#include <set>
#include <stdint.h>
#include <sys/epoll.h>
#include <sys/socket.h>

#include "epoll_socket.h"
#include "opFastdfs.h"
#include "message.h"
#include "log.h"
#include "md5.h"
#include "fileDataHandle.h"

class CVoiceEpollWatcher : public EpollSocketWatcher
{
	public:
		CVoiceEpollWatcher();

		virtual ~CVoiceEpollWatcher();
		
		virtual int on_accept(EpollContext &epoll_context);

		virtual int on_readable(int &epollfd, epoll_event &event);

		virtual int on_writeable(EpollContext &epoll_context);

		virtual int on_close(EpollContext &epoll_context);

	private:
		// handle client message
		bool handle_clientData(EpollContext *epoll_context, char clientData[], int dataLength);

};


class CVoiceServer
{

	public:
		CVoiceServer(const std::string& cIP, const uint32_t& uiBacklog, 
				const uint32_t& uiMaxEvents ,const uint32_t& uiPort);
		~CVoiceServer();

		bool StartServer();

	
	protected:

	private:
		std::string cIP;
		uint32_t uiBacklog;
		uint32_t uiMaxEvents;
		uint32_t uiPort;
		
		EpollSocket epoll_socket;
};
